﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Portal.Web.Global;
using Portal.Core;
using Portal.AssetTn.Model;

namespace Portal.Gui.Web.WebParts.AssetTn
{
    public class AssetUtility
    {
        public static WebPartServiceCls WebPartService
        {
            get
            {
                return new WebPartServiceCls("Asset.Tn", "Quản lý hiện vật");
            }
        }

        public static string GetLookUp(string SiteId, string Object,string JavascriptField, string CurrentValue)
        {
            if (Object.Equals("frkAssetStatusId"))
            {
                AssetStatusCls[] AssetStatus = new AssetStatusBll().ReadingAssetStatus(SiteId, "");
                string SelectAssetStatus =
                    "<select class=drplist type=combobox id=\"" + JavascriptField+Object + "\" style=\"width:100%;\">\r\n" +
                    "   <option value=\"\">== Chọn trạng thái ==</option>\r\n";
                for (int iIndex = 0; iIndex < AssetStatus.Length; iIndex++)
                {
                    if (CurrentValue.Equals(AssetStatus[iIndex].AssetStatusId))
                    {
                        SelectAssetStatus += "    <option selected value=\"" + AssetStatus[iIndex].AssetStatusId + "\">" + AssetStatus[iIndex].AssetStatusName + "</option>\r\n";
                    }
                    else
                    {
                        SelectAssetStatus += "    <option value=\"" + AssetStatus[iIndex].AssetStatusId + "\">" + AssetStatus[iIndex].AssetStatusName + "</option>\r\n";
                    }
                }
                SelectAssetStatus += "</select>";
                return SelectAssetStatus;
            }

            if (Object.Equals("frkAssetMaterialId"))
            {
                AssetMaterialCls[] AssetMaterial = new AssetMaterialBll().ReadingAssetMaterial(SiteId, "");
                string SelectAssetMaterial =
                    "<select class=drplist Material=combobox id=\""+JavascriptField+ Object + "\" style=\"width:100%;\">\r\n" +
                    "   <option value=\"\">== Chọn chất liệu ==</option>\r\n";
                for (int iIndex = 0; iIndex < AssetMaterial.Length; iIndex++)
                {
                    if (CurrentValue.Equals(AssetMaterial[iIndex].AssetMaterialId))
                    {
                        SelectAssetMaterial += "    <option selected value=\"" + AssetMaterial[iIndex].AssetMaterialId + "\">" + AssetMaterial[iIndex].AssetMaterialName + "</option>\r\n";
                    }
                    else
                    {
                        SelectAssetMaterial += "    <option value=\"" + AssetMaterial[iIndex].AssetMaterialId + "\">" + AssetMaterial[iIndex].AssetMaterialName + "</option>\r\n";
                    }
                }
                SelectAssetMaterial += "</select>";
                return SelectAssetMaterial;
            }


            if (Object.Equals("frkAssetNationalId"))
            {
                AssetNationalCls[] AssetNational = new AssetNationalBll().ReadingAssetNational(SiteId, "");
                string SelectAssetNational =
                    "<select class=drplist National=combobox id=\""+JavascriptField + Object + "\" style=\"width:100%;\">\r\n" +
                    "   <option value=\"\">== Chọn dân tộc ==</option>\r\n";
                for (int iIndex = 0; iIndex < AssetNational.Length; iIndex++)
                {
                    if (CurrentValue.Equals(AssetNational[iIndex].AssetNationalId))
                    {
                        SelectAssetNational += "    <option selected value=\"" + AssetNational[iIndex].AssetNationalId + "\">" + AssetNational[iIndex].AssetNationalName + "</option>\r\n";
                    }
                    else
                    {
                        SelectAssetNational += "    <option value=\"" + AssetNational[iIndex].AssetNationalId + "\">" + AssetNational[iIndex].AssetNationalName + "</option>\r\n";
                    }
                }
                SelectAssetNational += "</select>";
                return SelectAssetNational;
            }
            return "";
        }
    }
}
